package javafx179labs.nez.hr.bean.refactor;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author SSheypak
 */

/**Base abstraction for all beans*/
//abstract - do not allow to instantiate this class
public abstract class Entity {
    protected Integer id;
    protected String title;
    protected final Map<Integer, String> fieldMap = new HashMap<Integer, String>();

    //TODO: read about Java class initialization.
    {
        fieldMap.put(1, "id");
        fieldMap.put(2, "title");
    }


    /**This constructor is only for technical purposes.
     * It doesn't bring any logic.
     */
    protected Entity(){
        initMap();
    }

    /**Provides meta information about class fields.
     * Use fieldMap and add persistent in initMap fields if needed
     * @return map with pair: number of token=>fieldName*/
    protected Map<Integer,String> getFieldMapping(){
        return fieldMap;
    }

    /**Set values for field map
     * @return map with pairs: num=>fieldName
     */
    protected abstract void initMap();

    /**Set name of place where obj should be stored*/
    protected abstract String getPersistentStorageName();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }


}
